<template>
    <mu-container class="button-wrapper">
        <div style="background:#fff;">
            <mu-button color="primary" @click="applybh">
                <mu-icon left value="add"></mu-icon>
                申请保函
            </mu-button>
        </div>

        
        <bhcard v-for="(item, index) in tableData" :key="index" :data="item"></bhcard>
        
        <div>
            <page-list v-model="tableData" ref="page" :search.sync="pageData" :action="'/bhtong/ordermg/orderlist.json'">
            </page-list>
        </div>

        
    </mu-container>
</template>

<script>
import Vue from "vue"
import 'muse-ui-message/dist/muse-ui-message.css';
import Message from 'muse-ui-message';
export default {
    name: 'Order',
    data() {
        return {
            form: {
                tableData: []
            },
            pageData: {
                pagesize: 4
            },
            tableData: [],
            tableData1:[{
                type:"1",
                str2:"2",
                str5:"2",
                str19:"2",
            }],


        }
    },
    methods: {
        delBh(item) {
            let _this = this;
            this.$dialog.confirm({
                title: '提示',
                message: '确定删除吗？'
            }).then(() => {
                this.$api.delorder({
                    guaranteeid: item.str10
                }).then(function (data) {
                    _this.$toast.success('删除成功');
                    _this.$refs.page.queryData();
                })
            }).catch(() => {
                // on cancel
            });


        },
        payBeforeEdit(item) {
            this.$router.push({
                path: '/applyfirst',
                query: {
                    rowguid: item.str10
                }
            })
        },
        evaluateRate(item) {

        },
        delayOrder(item) {
            this.$router.push({
                path: '/delay',
                query: {
                    rowguid: item.str10
                }
            })
        },
        applyTk(item) {
            let _this = this;
            this.$prompt('请输入退款原因', '提示', {
                validator(value) {
                    return {
                        valid: value,
                        message: '请输入退款原因'
                    }
                }
            }).then(({
                result,
                value
            }) => {
                if (result) {
                    console.log(item)
                    let datas = {
                        tkdetail: value,
                        ordercode: item.str10
                    }
                    this.$api.applyordertk(datas).then(function (data) {
                        if (data.code) {

                        } else {
                            _this.$toast.success('退款成功')
                        }
                    })
                } else {

                }
            });
        },
        timeToSplit: function (date) {
            return date.split(' ')[0];
        },
        goDetail(item) {
            this.$router.push({
                path: '/orderdetail',
                query: {
                    rowguid: item.str10
                }
            })
        },
        handleState(state) {
            let states = {
                '0': {
                    type: '#909399',
                    text: '未创建'
                },
                '1': {
                    type: '#2979ff',
                    text: '待支付'
                },
                '2': {
                    type: '#00bcd4',
                    text: '审核中'
                },
                '3': {
                    type: '#dd2c00',
                    text: '被退回'
                },
                '4': {
                    type: '#67C23A',
                    text: '已转开'
                },
                '5': {
                    type: '#607d8b',
                    text: '样本待确认'
                },
                '6': {
                    type: '#67C23A',
                    text: '制单中'
                },
                '7': {
                    type: '#67C23A',
                    text: '已出函'
                },
                '8': {
                    type: '#67C23A',
                    text: '已邮寄'
                },
                '9': {
                    type: '#67C23A',
                    text: '已收函'
                },
                '10': {
                    type: '#F56C6C',
                    text: '样本异议'
                },
                '11': {
                    type: '#67C23A',
                    text: '申请延期'
                },
                '12': {
                    type: '#67C23A',
                    text: '延期通过'
                },
                '13': {
                    type: '#E6A23C',
                    text: '延期退回'
                },
                '14': {
                    type: '#67C23A',
                    text: '退款中'
                },
                '15': {
                    type: '#E6A23C',
                    text: '已退款'
                },
                '19': {
                    type: '#9e9e9e',
                    text: '已失效'
                }
            }
            return states[state]
        },
        applybh() {
            this.toPath({
                path: '/applyfirst',
            })
        },
        goPay(item) {
            this.$router.push({
                path: '/creatorder',
                query: {
                    rowguid: item.str10
                }
            })
        },
        editOrder(item) {
            this.$router.push({
                path: '/editorder',
                query: {
                    rowguid: item.str10
                }
            })
        }
    },
    created() {
        let validateForm = this.$store.state.first.form;
        let validateForm1 = this.$store.state.second.form;
        if (!validateForm.bidder && !validateForm1.earnest) {} else {
            this.$router.go(0)
        }
    }
}
</script>

<style lang="less" scoped>
.container {
    padding: 0;
}

.mu-bottom-item {
    max-width: 100%
}

.mu-inverse {
    color: #f18241;
    background: #fff;
    box-shadow: none;
    width: 100%;
    height: 45px;

}

.mu-card-title-container {
    text-align: left;
    color: #666666;
    padding-bottom: 0;

    .mu-card-title {
        font-size: 18px;
    }
}

.mu-card-text {
    text-align: left;
    color: #666666;
    padding-top: 0;
}

.mu-raised-button {
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, .12);
    color: #f18241;
}

.mu-card-actions {
    text-align: right;
}

.order_state {
    position: absolute;
    right: 15px;
    top: 25px;
}
.mu-card{
    box-shadow: none;
}
.mu-divider{
    margin: 0 auto;
    width: 95%;
}

/deep/ .van-card{
    background-color: white;
}
</style>
